///
/// Override this method to filter the ${Second Dropdown List Control}DropDownList
/// based on the value selected for the ${First Dropdown List Control}DropDownList
///
protected void Populate${Second Dropdown List Control}DropDown(int maxItems)
{
// Set up the WHERE clause.
// Create the WHERE clause to filter the second dropdown list based on the
// selected value in the first dropdown list.
WhereClause wc = new WhereClause();
string selectedValue = ${First Dropdown List Control}.SelectedValue;
string selectedText = ${First Dropdown List Control}.SelectedItem.Text;
wc.iAND(${${Table}ClassName}.${First Dropdown Field}, BaseFilter.ComparisonOperator.EqualsTo, selectedValue);
// Clear the contents of second dropdown list.
this.${Second Dropdown List Control}.Items.Clear();
// Add "Please Select" string to second dropdown list.
this.${Second Dropdown List Control}.Items.Insert(0, new ListItem(Page.GetResourceValue("Txt:PleaseSelect", "${Application Name}"), "--PLEASE_SELECT--"));
if(BaseClasses.Utils.StringUtils.InvariantUCase(selectedText).Equals(BaseClasses.Utils.StringUtils.InvariantUCase(Page.GetResourceValue("Txt:PleaseSelect", "${Application Name}"))))
{
// if "Please Select" string is selected for first dropdown list,
// then do not continue populating the second dropdown list.
return;
}
// Get the records using the created where clause.
foreach ( ${${Table}RecordClassName} itemValue in ${${Table}ClassName}.GetRecords(wc, null, 0, maxItems))
{
if(itemValue.${Second Dropdown Field}Specified)
{
// In each record, obtain the value of second dropdown field if value exists,
// create an item for it and add it to the list.
string cvalue = itemValue.${Second Dropdown Field}.ToString();
string fvalue = itemValue.Format(${${Table}ClassName}.${Second Dropdown Field});
ListItem item = new ListItem(fvalue, cvalue);
if (! this.${Second Dropdown List Control}.Items.Contains(item))
{
this.${Second Dropdown List Control}.Items.Add(item);
}
}
}
// Select "Please Select" string in the second dropdown list.
this.${Second Dropdown List Control}.SelectedIndex = 0;
}
|